Definition:
A stack data structure can be implemented using a one-dimensional array. 
But stack implemented using array stores only a fixed number of data values.
You just define a one dimensional array of specific size and insert or delete the values into that array by using LIFO principle with the help of a variable called 'top'.


Algorithm:

Creating a Stack

1 Start
2 An array of fixed size is used to implement a stack
3 Initially the top of the stack is made to store the value -1
4 Stop

Pushing data into the stack

1 Start
2 Read the data to be pushed into the stack
3 Push the read value in to the stack by incrementing the top of the stack as initially the stack top has -1 and top should not hold a negative value.
4 Thus the data is Pushed in to the stack
5 Stop


Popping the data out from the stack

1 Start
2 Check if top has the value -1 .if yes print that the stack is empty
3 Otherwise print the top of the stack element until top become equal to -1
4 Stop

Is empty

1 Start
2 If top is -1 then return 1 otherwise return 0
3 Stop


Let Us Do A Example:

  We have to push 5 elements 1,2,3,4,5 into stack

After pushing into the stack it looks like 

5

4

3

2

1

Now Let Us Pop the element '5' , '4' in the stack 

After Poping from the stack it looks like

3

2

1   

Here '5' , '4' gets poped out from the stack.

Let Us Do ISEMPTY function

Condition If Top is -1 then return 1 else return 0 (ie)return nothing

Now After doing Isempty we have stack look like

3

2

1 

At Last We have the elements in the stack as

1 2 3.








